package sk.isomi.minihr.entities;

import java.util.ArrayList;
import java.util.List;


public class Employee extends Person {
	private String company;
	private Double salary;
	private List<Project> projects;
	private Manager manager;
	
	public Employee(String id, String prefix, String name, String surname,	String birthNumber, Double salary, String company) {
		super(id, prefix, name, surname, birthNumber);
		setSalary(salary);
		setCompany(company);
		projects = new ArrayList<Project>();
	}

	public Employee(String id, String surname, String birthNumber) {
		super(id, surname, birthNumber);
		projects = new ArrayList<Project>();
	}
	

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public Double getSalary() {
		return salary;
	}

	public void setSalary(Double salary) {
		this.salary = salary;
	}

	public List<Project> getProjects() {
		return projects;
	}

	public void setProjects(List<Project> projects) {
		this.projects = projects;
	}	
	
	public Manager getManager() {
		return manager;
	}

	public void setManager(Manager manager) {
		this.manager = manager;
	}	
	
	@Override
	protected boolean validateId(String id) throws RuntimeException {
		return id != null && id.matches("E\\d{2}");		
	}	
	
	@Override
	public String toString() {
		return String.format("Employee [company=%s, salary=%s, getId()=%s, getName()=%s, getSurname()=%s]",
						company, salary, getId(), getName(), getSurname());
	}
	
	@Override
	public boolean equals(Object obj) {
		return obj != null && obj instanceof Employee && ((Employee) obj).getId().equalsIgnoreCase(getId());
	}
}
